﻿using Coolzon.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Coolzon.UI.Common.Event.NCL
{
    /// <summary>
    /// network control logic event bus
    /// </summary>
    public static class NCLEventBus
    {
        private static object s_lockObj = new object();
        private static EventBus s_instance;

        private static EventBus Instance
        {
            get
            {
                if (s_instance == null)
                {
                    lock (s_lockObj)
                    {
                        if (s_instance == null)
                        {
                            s_instance = EventBus.Create("NCL");
                        }
                    }
                }
                return s_instance;
            }
        }

        public static void Register(object receiver)
        {
            Instance.Register(receiver);
        }

        public static void Unregister(object receiver)
        {
            Instance.Unregister(receiver);
        }

        public static void Publish(NCLEvent @event)
        {
            Instance.Publish(@event);
        }

        public static void PublishAsync(NCLEvent @event)
        {
            Instance.PublishAsync(@event);
        }
    }
}
